//https://leetcode.cn/submissions/detail/560663155/
class Solution {
public:
    int minSubArrayLen(int target, vector<int>& nums) {
        using ll = long long;
        ll l = 0, sum = 0;
        ll ans = 1e9;
        for (int r = 0; r < nums.size(); r++)
        {
            sum += nums[r];
            while (sum >= target)ans = min(ans, r - l + 1), sum -= nums[l], l++;
        }
        if (ans == 1e9)return 0;
        return ans;
    }
};